﻿Imports NUnit.Framework
Imports System.Data.SqlClient
Imports KumaSystem.Activities.MSSQL

<TestFixture()>
Public Class TestSQLExecute

    Private _connString As String = ""
    Private _server As String = "localhost"
    Private _database As String = "test_db"
    Private _username As String = "test"
    Private _password As String = ""

    <SetUp()>
    Public Sub Setup()
        Dim sqlConBuilder As New SqlConnectionStringBuilder
        With sqlConBuilder
            .DataSource = _server
            .InitialCatalog = _database
            .IntegratedSecurity = True
        End With
        _connString = sqlConBuilder.ConnectionString
    End Sub

    <Test()>
    Public Sub TestRaiseError()
        Dim sqlExec As New SQLExecute
        Assert.True(sqlExec.OutputSQLLog("ユニットテストによるエラー出力", 1, 1, _connString))

        'sysadmin 権限を持たないアカウントでの出力テスト
        Dim sqlConBuilder As New SqlConnectionStringBuilder
        With sqlConBuilder
            .DataSource = _server
            .InitialCatalog = _database
            .IntegratedSecurity = False
            .UserID = _username
            .Password = _password
        End With
        _connString = sqlConBuilder.ConnectionString
        Assert.False(sqlExec.OutputSQLLog("ユニットテストによるエラー出力", 1, 1, _connString))
    End Sub
End Class
